| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | List of all members
nkAstraeus::FilmGrainEffect Class Referencefinal

A film grain effect. More...

Inheritance diagram for nkAstraeus::FilmGrainEffect:

## Public Member Functions
| FilmGrainEffect (System *system) noexcept
virtual | ~FilmGrainEffect ()
nkGraphics::Texture * | getSourceTexture () const
float | getStrength () const
bool | getRgbNoise () const
bool | getBlendGrainInTarget () const
void | setSourceTexture (nkGraphics::Texture *value)
void | setStrength (float value)
void | setRgbNoise (bool value)
void | setBlendGrainInTarget (bool value)
virtual bool | load () override
virtual void | unload () override
Public Member Functions inherited from nkAstraeus::Effect
| Effect (EFFECT_TYPE type) noexcept
virtual | ~Effect ()
nkMemory::StringView | getName () const
nkGraphics::Shader * | getShader () const
EFFECT_TYPE | getType () const
void | setName (nkMemory::StringView value)

## Static Public Member Functions
static nkMemory::UniquePtr< FilmGrainEffect > | create (System *system=nullptr)

## Detailed Description

A film grain effect.

This effect imitates the noise often present in pictures taken from a camera. Some potential causes can be dirt or imperfections on the sensor lens, compression artifacts, or dust on the film. It is useful to add a sense of reality to an image, by adding imperfection usually found when taking real pictures. This effect offers different settings to make the effect look different, but also to make it adapt to different situations.

## Constructor & Destructor Documentation

## ◆ FilmGrainEffect()

nkAstraeus::FilmGrainEffect::FilmGrainEffect | ( | System * | system | ) |
| noexcept

Default constructor. Alternatively, see FilmGrainEffect::create(), or EffectManager::createOrRetrieve().

Parameters

  system | The system the resource should live in.

## ◆ ~FilmGrainEffect()

virtual nkAstraeus::FilmGrainEffect::~FilmGrainEffect | ( |  | ) |
| virtual

Destructor. See EffectManager::erase().

## Member Function Documentation

## ◆ getSourceTexture()

nkGraphics::Texture* nkAstraeus::FilmGrainEffect::getSourceTexture | ( |  | ) | const

Returns
  The source texture currently used.

## ◆ getStrength()

float nkAstraeus::FilmGrainEffect::getStrength | ( |  | ) | const

Returns
  The set strength of the effect.

## ◆ getRgbNoise()

bool nkAstraeus::FilmGrainEffect::getRgbNoise | ( |  | ) | const

Returns
  Whether the noise is a RGB noise (true) or not (false).

## ◆ getBlendGrainInTarget()

bool nkAstraeus::FilmGrainEffect::getBlendGrainInTarget | ( |  | ) | const

Returns
  Whether the effect is blended in the output (true) or not (false).

## ◆ setSourceTexture()

void nkAstraeus::FilmGrainEffect::setSourceTexture | ( | nkGraphics::Texture * | value | ) |

Sets the texture to use as input. This texture is only required when the blending functionality is turned off.

Parameters

  value | The texture to use as input for the effect.

Remarks
  If the effect was loaded without blending activated, this parameter can be updated without reloading the effect. Else, the effect has to be reloaded with the blending flag set to false before this can have an effect.

## ◆ setStrength()

void nkAstraeus::FilmGrainEffect::setStrength | ( | float | value | ) |

Sets the strength of the effect. Defaults to 0.15.

Parameters

  value | The strength of the effect wanted.

Remarks
  This parameter can be updated without reloading the effect.

## ◆ setRgbNoise()

void nkAstraeus::FilmGrainEffect::setRgbNoise | ( | bool | value | ) |

Sets whether the noise should randomize its output on the RGB channels independently, or with one value on all of them at once. If false, this means that noise will be applied like : r + n, g + n, b + n. If true, this means that noise will be applied like : r + n0, g + n1, b + n2. Defaults to false.

Parameters

  value | Whether the noise should be independent on each channel (true) or not (false).

Remarks
  This parameter requires the effect to be reloaded if it was already loaded with a different value.

## ◆ setBlendGrainInTarget()

void nkAstraeus::FilmGrainEffect::setBlendGrainInTarget | ( | bool | value | ) |

Sets whether the effect should blend in the target, or rather process the source texture before writing the output. See FilmGrainEffectUtils::prepareBlendStateForGrainBlending() to setup a compatible BlendState to use in the pass along with the effect. Defaults to false.

Parameters

  value | Whether the noise should be blended in target (true) or not (false).

Remarks
  If updated, this parameter needs the effect to be reloaded to take effect.
  If set to true, the effect expects to work together with the blend state given by FilmGrainEffectUtils. The source is then ignored and not required. texture

## ◆ load()

virtual bool nkAstraeus::FilmGrainEffect::load | ( |  | ) |
| override virtual

Loads the effect and make it ready for rendering.

Returns
  Whether the loading went well (true) or not (false).

Implements nkAstraeus::Effect.

## ◆ unload()

virtual void nkAstraeus::FilmGrainEffect::unload | ( |  | ) |
| override virtual

Unloads the effect and its internal memory. After that, the effect is unusable for rendering.

Implements nkAstraeus::Effect.

## ◆ create()

static nkMemory::UniquePtr<FilmGrainEffect> nkAstraeus::FilmGrainEffect::create | ( | System * | system = `nullptr` | ) |
| static

Creates an instance of the class, and returns ownership over it.

Parameters

  system | The system the resource should live in. If left to nullptr, will seek the singleton instance of the system.

Returns
  Ownership over the created instance of the class.

Remarks
  The instance is not part of any manager if instantiated this way. If the resource's lifetime should be managed within the manager, then calling ComplexEffectManager::createOrRetrieve() might be a better option. Alternatively, registering it afterwards through ComplexEffectManager::record() is another option.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsAstraeus/Graphics/Effects/FilmGrain/FilmGrainEffect.h